import request from '@/utils/request';

//列表
export const getServerList = (data) => {
  return request({
    url: `/mcp/mcp_server_list`,
    method: 'get',
  });
};

//添加 mcpServer
export const addMcpServer = (data) => {
  return request({
    url: `/mcp/mcp_server`,
    method: 'post',
    data: data,
  });
};

//修改 mcpServer
export const updateMcpServer = (data) => {
  return request({
    url: '/mcp/mcp_server',
    method: 'put',
    data: data,
  });
};

//删除 mcpServer
export const delMcpServer = (data) => {
  return request({
    url: `/mcp/mcp_server/${data.id}`,
    method: 'delete',
    data: data,
  });
};

//查看 mcpServer
export const getMcpServer = (data) => {
  return request({
    url: `/mcp/mcp_server/${data.id}`,
    method: 'get',
  });
};

// 查看会话
export const getChatList = (data) => {
  return request({
    url: `/chat_window/chat_window_list`,
    method: 'get',
  });
};

// 普通会话
export const getNormalChat = (data) => {
  return request({
    url: `/chat/normal_chat`,
    method: 'post',
    data: data,
  });
};

// 用户注册
export const userRegister = (data) => {
  return request({
    url: `/user/user`,
    method: 'post',
    data: data,
  });
};

// 用户登录
export const userLogin = (data = {}) => {
  const formData = new FormData();
  formData.append('username', data.username);
  formData.append('password', data.password);

  return request({
    url: `/auth/login`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};


// 用户token信息
export const getTokeninfo = () => {
  return request({
    url: `/user/tokeninfo`,
    method: 'get',
  });
};

// 退出登录
export const userLogout = () => {
  return request({
    url: `/auth/logout`,
    method: 'post',
  });
};


// 全量模版
export const getTemplates = () => {
  return request({
    url: `/llm/templates`,
    method: 'get',
  });
};


// 用户信息
export const getConfigs = () => {
  return request({
    url: `/llm/configs`,
    method: 'get',
  });
};

// 新增
export const addConfigs = (data) => {
  return request({
    url: `/llm/config`,
    method: 'post',
    data: data,
  });
};

// 修改
export const updateConfigs = (data) => {
  return request({
    url: `/llm/config`,
    method: 'put',
    data: data,
  });
};

// 获取制品模版列表
export const template_list = () => {
  return request({
    url: `/artifacts/template_list`,
    method: 'get',
  });
};


// mcp应用列表
export const getMcpList = (data) => {
  return request({
    url: `/mcp_app/page`,
    method: 'get',
    params: data,
  });
};


// 回话详情
export const getChatDetail = (data) => {
  return request({
    url: `/chat_window/detail/${data.id}`,
    method: 'get',
  });
};

/************ 新 ******************/

// 获取所有已启用mcp_server集合
export const applied_list = (data) => {
  return request({
    url: `/mcp_server/enabled_list`,
    method: 'get',
    params: data,
  });
};

// 查询所有会话历史
export const conversationList = (data) => {
  return request({
    url: `/conversation/list`,
    method: 'get',
    params: data,
  });
};


// 查询指定会话历史
export const conversation = (data) => {
  return request({
    url: `/conversation`,
    method: 'get',
    params: data,
  });
};


// 批量删除会话
export const delConversation = (data) => {
  return request({
    url: `/conversation/list`,
    method: 'delete',
    data: data,
  });
};

// 删除会话片段
export const delMsgItem = (data) => {
  return request({
    url: `/conversation/dialog_segment`,
    method: 'delete',
    data: data,
  });
};


// 修改会话主题
export const changeConversationTheme = (data) => {
  return request({
    url: `/conversation/theme`,
    method: 'put',
    params: data,
  });
};


// 获取指定模型厂商配置集合
export const firmList = (data) => {
  return request({
    url: `/model/firm/list`,
    method: 'get',
    params: data,
  });
};

// 获取项目中指定厂商支持的所有模型
export const modelList = (data) => {
  return request({
    url: `/model/model/list`,
    method: 'get',
    params: data,
  });
};

// 获取指定模型厂商配置
export const userllmByFirm = (data) => {
  return request({
    url: `/user_setting/llm_firm`,
    method: 'get',
    params: data,
  });
};


// 设置指定厂商api_key
export const setllm = (data) => {
  return request({
    url: `/user_setting/llm_firm`,
    method: 'put',
    params: data,
  });
};

// 启用或禁用模型
export const modelEnable = (data) => {
  return request({
    url: `/model/model/enable`,
    method: 'put',
    params: data,
  });
};

// 获取项目中指定厂商启用的所有模型
export const getEnabledModelList = (data) => {
  return request({
    url: `/model/enabled_model/list`,
    method: 'get',
    params: data,
  });
};


// LLM生成器接口
export const generatorsChat = (data) => {
  return request({
    url: `/generators/chat`,
    method: 'post',
    data: data,
  });
};


// 测试
export const test_prompt = (data) => {
  return request({
    url: `/test/test_prompt`,
    method: 'post',
    data: data,
  });
};


// 团队chat
export const teamsChat = (data) => {
  return request({
    url: `/teams/chat`,
    method: 'post',
    data: data,
  });
};

// 查询当前会话计划接口
export const plan = (data) => {
  return request({
    url: `/plan`,
    method: 'get',
    params: data,
  });
};


// 计划修改接口
export const updatePlan = (data) => {
  return request({
    url: `/plan`,
    method: 'put',
    data: data,
  });
};


// 用户确认
export const confirmMcp = (data) => {
  return request({
    url: `/generators/confirm`,
    method: 'PUT',
    data: data,
  });
};


// 停止生成
export const stopChat = (data) => {
  return request({
    url: `/generators/stop`,
    method: 'PUT',
    params: data,
  });
};




// 获取全部agent接口
export const getAgent = (data) => {
  return request({
    url: `/agent/load_all`,
    method: 'get',
    params: data,
  });
};



